package io.renren.modules.tbposition.controller;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.alarmonline.entity.AreaalarmOnlineEntity;
import io.renren.modules.welderunnormal.entity.WelderunnormalEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.tbposition.entity.TbPositionEntity;
import io.renren.modules.tbposition.service.TbPositionService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-18 11:55:21
 */
@RestController
@RequestMapping("tbposition/tbposition")
public class TbPositionController {
    @Autowired
    private TbPositionService tbPositionService;


    @GetMapping("getTbPos")
    public List<TbPositionEntity> getTbPos(){
        return tbPositionService.getTbPos();
    }

    @PostMapping(value = "/testadd",produces = {"application/json;charset=UTF-8"})
    public void addItem(@RequestBody TbPositionEntity tbPositionEntity){
        tbPositionService.insertItem(tbPositionEntity);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("tbposition:tbposition:list")
    public R list(@RequestParam Map<String, Object> params) throws IOException {
        PageUtils page = tbPositionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{position}")
    @RequiresPermissions("tbposition:tbposition:info")
    public R info(@PathVariable("position") String position){
		TbPositionEntity tbPosition = tbPositionService.getById(position);

        return R.ok().put("tbPosition", tbPosition);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("tbposition:tbposition:save")
    public R save(@RequestBody TbPositionEntity tbPosition){
		tbPositionService.save(tbPosition);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("tbposition:tbposition:update")
    public R update(@RequestBody TbPositionEntity tbPosition){
		tbPositionService.updateById(tbPosition);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("tbposition:tbposition:delete")
    public R delete(@RequestBody String[] positions){
		tbPositionService.removeByIds(Arrays.asList(positions));

        return R.ok();
    }

}
